count characters in string without using inbuilt methods